﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Krilib.Data;

namespace Krile.Forms.Dialogs.Editor
{
    public partial class TabEditor : Form
    {
        SearchDataCluster ctabSdc;
        bool inheritUnNotify;
        MainForm.Controls.XTab.XTabTLItem par;

        internal Data.TabData TabData
        {
            get
            {
                var td = new Data.TabData(par);
                td.Name = this.tabName.Text;
                td.ContainSearchData = ctabSdc;
                return td;
            }

            set
            {
                ctabSdc = value.ContainSearchData;
                tabName.Text = value.Name;
                inheritUnNotify = value.UnNotify;
                par = value.Parent;
            }
        }

        public TabEditor()
        {
            InitializeComponent();
            ctabSdc = new SearchDataCluster();
            inheritUnNotify = false;
            par = null;
        }

        private void tabName_TextChanged(object sender, EventArgs e)
        {
            OKBtn.Enabled = tabName.Text != String.Empty;
        }

        private void sdEditBtn_Click(object sender, EventArgs e)
        {
            using (var sdce = new SearchData.SearchDataClusterEditor())
            {
                sdce.SearchDataCluster = ctabSdc;
                if (sdce.ShowDialog() == DialogResult.OK)
                    ctabSdc = sdce.SearchDataCluster;
            }
        }
    }
}
